#!/usr/bin/python

import os
import sys

if len(sys.argv) <> 3:
	print "Usage: %s input output" % sys.argv[0]
	exit(0)

input = sys.argv[1]
output = sys.argv[2]

if not os.path.exists(input):
	print "File %s is not exist" % input
	exit(0)

if not os.access(input, os.R_OK):
	print "Can't read file %s" % input

if os.path.exists(output):
	print "File %s is already exist, please remove it first" % output
	exit(0)

try:
	f1 = open(input, 'r')
except IOError:
	print "Can't open input file %s" % input
	exit(0)

try:
	f2 = open(output, 'w')
except IOError:
	print "Can't open output file %s" % output
	exit(0)

r = f1.read()
l = len(r)
print "length = ", l
f2.write(r)
print "%d bytes written" % l

exit(0)
